<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>医疗机构列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jq.js"></script>
<script src="js/admin.js"></script>
</head>
<body>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">菜单信息列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li> <a class="button border-main icon-plus-square-o"
					 href="page/menu/addMenu.jsp"> 添加菜单</a> </li>
					<li>搜索：</li>
					<li><input type="text" placeholder="请输入搜索关键字" name="keywords"
						class="input"
						style="width:250px; line-height:17px;display:inline-block" /> <a
						href="javascript:void(0)" class="button border-main icon-search"
						onclick="changesearch()"> 搜索</a></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
				<th width="10%">菜单编号</th>
				<th width="14%">菜单名称</th>
				<th width="12%">上级菜单编号</th>
				<th width="35%">url</th>
				<th width="310">操作</th>
			</tr>
				
			<c:forEach items="${pu.list }" var="m">
				<tr>
					<td>${m.menuId }</td>
					<td>${m.menuName }</td>
					<td>${m.menupId }</td>
					<td width="30%">${m.url }</td>
					<td><div class="button-group">
							<a class="button border-main" href="MenuServlet?method=findMenuBymenuId&&menuId=${m.menuId}">
							<span class="icon-edit"></span> 修改</a> 
							<a class="button border-red" href="javaScript:void(0)" onclick="del('${m.menuId}','${pu.index }')">
							<span class="icon-trash-o"></span> 删除</a>
						</div></td>
				</tr>
			</c:forEach>
			</table>
			<div class="pagelist"> 
	        <a href="MenuServlet?method=findMenu&index=1">首页</a>
	        <c:if test="${pu.index !=1 }">
				<a href="MenuServlet?method=findMenu&index=${pu.index-1 }">上一页</a>
			</c:if> 
			<c:if test="${pu.index ==1 }"><a href="javascript:void(0)">上一页</a></c:if> 
			
			 
			 
			 <c:forEach items="${pu.numbers }" var="numb">
						<c:if test="${numb == pu.index }">
			<span class="current">${numb }</span>
			
			</c:if>
				<c:if test="${numb != pu.index }">
					<a href="MenuServlet?method=findMenu&index=${numb }">${numb }</a>
				</c:if>
			</c:forEach> 
					
					
			<c:if test="${pu.index !=pu.totalPageCount }">
				<a href="MenuServlet?method=findMenu&index=${pu.index+1 }">下一页</a>
			</c:if> 
			<c:if test="${pu.index ==pu.totalPageCount }">
			<a href="javascript:void(0)">下一页</a>
			</c:if> 
			 
			<a href="MenuServlet?method=findMenu&index=${pu.totalPageCount }">尾页</a>
			 共${pu.totalCount }条记录
			  </div>
		</div>
	</form>

</body>
<script type="text/javascript">
	function del(menuId,index) {
		if (confirm("您确定要删除吗?")) {
			$.post("MenuServlet", {method:"MenuDelete",menuId:menuId}, function(data) {
				if (eval(data)) {
					alert("用户删除成功！")
					window.location.href = "MenuServlet?method=findMenu&&index="+index
				} else {
					alert("删除失败")
				}
			})
		}
	}
</script>
</html>
